{#include file="top.php"#}
<div class="body">
    <div class="main">
        <form id="register_form" enctype="multipart/form-data" action="member.php?action=regTrial" method="POST">
            <div class="reg_step_box"></div>

            <div class="try_daren b_box">
                <div class="hd">
                    <h2 class="hd_title">試用達人</h2>
                </div>
                <div class="bd">
                    <p class="c_title">
                        成為〈試用專員〉，參加我們的試用活動
                    </p>

                    <table border="0" cellspacing="0" cellpadding="0" class="try_tb">

        <!--<tr>
                <th>出生日期<span class="span_pink">*</span>：</th><td>
                <input type="text" id="birthday" name="birthday" value="{#$layout.member.birthday#}" class="ipt"></td>
        </tr>
        <tr>
                <th></th><td><p class="tip" style="display:none;" id="birthday_tip">
                <em class="hack"></em>
                <a class="close" href="#"> close </a>
                <span id="birthday_err_text">{#$ERR_BIRTH#}</sapn>
        </p></td>
        </tr>
                        -->
                        <tr>
                            <th>行業<span class="span_pink" >*</span>：</th><td>
                                <select class="try_select" id='profession' name='profession'  onclick="$('#profession_err').hide();">
                                    <option value=''>Please Select</option>
                                    {#foreach from=$layout.profession item=v key=k#}
                                    <option  {#if $layout.member.profession==$v.id#}selected{#/if#}  value='{#$v.id#}'>{#$v.cname#}</option>
                                    {#/foreach#}
                                </select></td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="profession_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="profession_err_text">{#$HAS_PROFESSION#}</span>
                                </p></td>
                        </tr>
                        <tr>
                            <th>身型<span class="span_pink">*</span>：</th><td>
                                <select class="try_select" id='body' name='body'  onclick="$('#body_err').hide();">
                                    <option value=''>Please Select</option>
                                    {#foreach from=$layout.body item=v key=k#}
                                    <option  {#if $layout.member.body==$v.id#}selected{#/if#}   value='{#$v.id#}'>{#$v.cname#}</option>
                                    {#/foreach#}
                                </select></td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="body_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="body_err_text">{#$HAS_BODY#}</span>
                                </p></td>
                        </tr>
                        <tr>
                            <th>臉部膚質<span class="span_pink">*</span>：</th><td>
                                <select class="try_select" id='face_skin' name='face_skin'  onclick="$('#face_skin_err').hide();">
                                    <option value=''>Please Select</option>
                                    {#foreach from=$layout.face_skin item=v key=k#}
                                    <option  {#if $layout.member.face_skin==$v.id#}selected{#/if#}  value='{#$v.id#}'>{#$v.cname#}</option>
                                    {#/foreach#}
                                </select></td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="face_skin_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="face_skin_err_text">{#$HAS_FACE_SKIN#}</span>
                                </p></td>
                        </tr>
                        <tr>
                            <th>身體膚質<span class="span_pink">*</span>：</th><td>
                                <select class="try_select" id='body_skin' name='body_skin'  onclick="$('#body_skin_err').hide();">
                                    <option value=''>Please Select</option>
                                    {#foreach from=$layout.body_skin item=v key=k#}
                                    <option  {#if $layout.member.body_skin==$v.id#}selected{#/if#}  value='{#$v.id#}'>{#$v.cname#}</option>
                                    {#/foreach#}
                                </select></td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="body_skin_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="body_skin_err_text">{#$HAS_BODY_SKIN#}</span>
                                </p></td>
                        </tr>
                        <tr>
                            <th>髮質<span class="span_pink">*</span>：</th><td>
                                <select class="try_select" id='hair' name='hair' onclick="$('#hair_err').hide();">
                                    <option value=''>Please Select</option>
                                    {#foreach from=$layout.hair item=v key=k#}
                                    <option  {#if $layout.member.hair==$v.id#}selected{#/if#}  value='{#$v.id#}'>{#$v.cname#}</option>
                                    {#/foreach#}
                                </select></td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="hair_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="hair_err_text">{#$HAS_HAIR#}</span>
                                </p></td>
                        </tr>
                        <!--<tr>
                                <th>聯絡方法<span class="span_pink">*</span>：</th><td>
                                <input type="text" class="try_ipt_text" maxlength="11" id="phone" name="phone" value="{#$layout.member.phone#}"/>
                        </tr>
                        <tr>
                                <th></th><td><p style="display:none;" id="phone_err">
                                <em class="hack"></em>
                                <a class="close" href="#"> close </a>
                                <span id="phone_err_text">{#$ERR_PHONE#}</span>
                        </p></td>
                        </tr>
                        -->
                        <tr><th class="address">
                                郵寄地址<span class="span_pink">*</span>：</th>
                            <td><textarea class="daren_textarea" rows="8" cols="40" name="address" id="address"  onclick="$('#address_err').hide();" onchange="$('#address_err').hide();" onblur="$('#address_err').hide();" onkeydown="$('#address_err').hide();">{#$layout.member.address#}</textarea>
                                (星期一至五辦公時間內，有效簽收產品之中文商業地址)
                            </td>
                        </tr>
                        <tr>
                            <th></th><td><p class="tip" id="address_err" style="display:none;">
                                    <em class="hack"></em>
                                    <a class="close" href="#"> close </a>
                                    <span id="address_err_text">{#$HAS_ADDRESS#}</span>
                                </p></td>
                        </tr>
                    </table>

                </div>
                <input type="hidden" name="issubmit" value="1" />
                <a style="cursor:pointer" name="Submit" onclick="submit_form()" class="btn_s btn_s_next"><strong>下一步</strong></a> <a href="{#$this->selfurl#}?action=regSucceed&toURL={#$toURL#}" class="btn_s btn_s_ignore"><strong>略過</strong></a>

            </div>
        </form>
    </div>

    <!-- main-->
    <div class="sidebar">
        {#show_block('b2',1,'','sidebar_ad')#}
        {#show_block('b1',2,'','sidebar_function')#}
        {#show_block('b3',0,'','sidebar_search')#}
        {#show_block('b4',0,'','sidebar_workshop')#}
        {#show_block('b5',0,'','sidebar_top3 b_box')#}
    </div>
    <!-- sidebar -->

</div><!--body-->
<link rel="stylesheet" href="js/ui/jquery-ui-1.8.8.custom.css">
<script src="js/ui/jquery-ui-1.8.8.custom.min.js"></script>

<script>
    $(document).ready(function(){
        /*
$('#phone').mousedown(check_register_phone);
$('#phone').keyup(check_register_phone);

$('#birthday').mousedown(check_register_birthday);
$('#birthday').click(check_register_birthday);

$("#birthday").datepicker({
                        changeMonth: true,
                        changeYear: true,
                        defaultDate: new Date(1990, 1 - 1, 1),
                        dateFormat:'yy-mm-dd',
                        minDate:new Date(1900, 1 - 1, 1),
                        yearRange: '1900:2010'
                        //showOn: "button",
                        //buttonImage: "js/ui/images/calendar.gif",
                        //buttonImageOnly: true
                });
         */

    });
    function check_cssby(tipmainname){

        var obj =$("#"+tipmainname+"_err");
        if(obj.attr('class')!='tip'){
            return 1;
        }else{
            return 0;
        }
    }

    function check_register_birthday(){
        var birthday=$('#birthday').val();
        if(birthday == ''){
            $("#birthday_err").addClass("tip").show();
            $("#birthday_err_text").html('{#$ERR_BIRTH#}');
            return 0;
        }else{
            $("#birthday_err").removeClass("tip").hide();
            return 1;
        }
    }

    function check_register_phone(){
        var rt = 0;
        var phone=$('#phone').val();
        //if(phone.length>0){
        if(phone.match(/^[0-9]{8,11}$/) == null){
            $("#phone_err").addClass("tip").show();
            $("#phone_err_text").html('{#$ERR_PHONE#}')
            //}else if(phone.length<8){
            //$("#phone_err").addClass("tip").html('{#$ERR_PHONE#}').show();
        }else{

            $('#phone_err').addClass("tip").show();
            $("#phone_err_text").html('{#$CHECKING#}');

            $.get("member.php?action=ajax_checkPhone",{phone:phone,act:"check_phone"},function(data){
                if(data == 1){
                    $("#phone_err").removeClass("tip").hide();
                    rt =  1;
                }else if(data == -1) {
                    //$("#phone_err").addClass("tip").show();
                    $("#phone_err_text").html('{#$ERR_PHONE#}')
                }else if(data == -2) {
                    //$("#phone_err").addClass("tip").show();
                    $("#phone_err_text").html('{#$HAS_PHONE#}')
                }
            });

        }
        /*}else{
                        rt =  1;
                        $("#phone_err").removeClass("tip").hide();
                }*/
        return rt;
    }

    function submit_form(){

        var ck = {
            //'birthday'			:["{#$ERR_BIRTH#}",3],
            'profession'		:["{#$HAS_PROFESSION#}",1],
            'body'				:["{#$HAS_BODY#}",1],
            'face_skin'			:["{#$HAS_FACE_SKIN#}",1],
            'body_skin'			:["{#$HAS_BODY_SKIN#}",1],
            'hair'				:["{#$HAS_HAIR#}",1],
            //'phone'				:["{#$ERR_PHONE#}",3],
            'address'			:["{#$HAS_ADDRESS#}",3]};
        var ck_ok =1;
        $.each(ck,function(i,n){
            switch(n[1]){
                case 1:

                    var o = $('#'+i);


                    if(o.val()==0){
                        //alert(n[0]);
                        ck_ok = 0;
                        o.focus();
                        $('#'+i+'_err').show();
                        return false;
                    }
                    break;
                case 2:
                    if(!check_checkbox(i)){
                        //alert(n[0]);
                        ck_ok = 0;
                        $('[name="'+i+'"]').eq(0).focus();

                        var l=i.length;
                        $('#'+i.substr(0,l-2)+'_err').show();
                        return false;
                    }
                    break;
                case 3:
                    var o = $('#'+i);
                    if($.trim(o.val()).length==0){
                        //alert(n[0]);
                        ck_ok = 0;
                        o.focus();
                        $('#'+i+'_err').show();
                        return false;
                    }
                    break;
            }
        });
        if(check_cssby('phone') != 1){
            $('#phone').focus();
            //alert("{#$ERR_PHONE#}");
            ck_ok = 0;
            $("#phone_err").addClass("tip").show();
            $("#phone_err_text").html('{#$ERR_PHONE#}')
            return false;
        }
        if(ck_ok){
            $("#register_form").submit();
        }
    }
</script>
{#include file="footer.php"#}